<?php /*0*/

/**
  *	This file contains a class
  *
  *	@author Vytenis Urbonavicius <vytenis.urbonavicius@myhost.lt>
  *	@package CMS
  *	@version 0.0
  */

if ( !defined( 'SECURITY' ) ) {
	die( 'Direct access to this script is not allowed!' );
}

/**
  *	This class is for operations with arguments
  *
  *	@author Vytenis Urbonavicius <vytenis.urbonavicius@myhost.lt>
  *	@version 0.0
  */
class Arguments {
	
	/**
	  *	This method gathers an argument from argument array
	  *	<br />
	  *	Argument array is the most common way of passing arguments in this CMS
	  *
	  * <br /><br />
	  *	Note that parameters are located in an associative array
	  *
	  *	@author Vytenis Urbonavicius <vytenis.urbonavicius@myhost.lt>
	  *	@access public
	  *	@version 0.0
	  *
	  * @static
	  *
	  * @param array $arguments - this is an associative array <br /><br />
	  * It contains: <br />
	  * 	- title - string title/name of an argument ( argument array key ) <br />
	  * 	- argument_array - array of arguments <br />
	  *
	  *	@return mixed/false argument or false on error
	  */
	public static function getArgument( $arguments ) {
	
		$title = null;
		$argument_array = array();
		
		if ( ( !empty( $arguments['title'] ) ) && ( is_string( $arguments['title'] ) ) && ( !empty( $arguments['argument_array'] ) ) && ( is_array( $arguments['argument_array'] ) ) ) {
			$title = $arguments['title'];
			$argument_array = $arguments['argument_array'];
		} else {
			return false;
		}
		
		if ( isset( $argument_array[$title] ) ) {
			if ( empty( $argument_array[$title] ) && ( (string)$argument_array[$title] !== '0' ) ) {
				$result = false;
			} else {
				$result = $argument_array[$title];
			}
		} else {
			$result = false;
		}
		
		return $result;
	}

}

?>